#include<bits/stdc++.h>
using namespace std;

typedef long long i64;
const i64 inf = 0x3f3f3f3f3f3f3f3f;
i64 T;
i64 n, m, L; double V;
struct car{
    i64 d, v, a;
}c[100005];
i64 p[200005];

i64 flg[200005];
i64 sum[200005];
i64 ansc = 0;
vector <pair<i64, i64> > qj;
vector <i64> plc;
void cf(i64 l, i64 r){
    if(l > r) return;
    i64 ll = 0, rr = m + 1, p1, p2;
    while(ll < rr){//cout << ll << endl;
        i64 mid = (ll + rr) >> 1LL;
        if(p[mid] >= l) rr = mid;
        else ll = mid + 1;
    }
    p1 = ll;
    ll = 0, rr = m + 1;
    while(ll < rr){
        i64 mid = (ll + rr + 1LL) >> 1LL;
        if(p[mid] <= r) ll = mid;
        else rr = mid - 1;
    }
    p2 = ll;
    if(p1 <= p2) flg[p1]++, flg[p2 + 1]--, ansc++, qj.push_back(make_pair(p2, p1));
}

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> T;
    while( T-- ){
        cin >> n >> m >> L >> V;
        for(i64 i=1;i<=n;++i) cin >> c[i].d >> c[i].v >> c[i].a;
        for(i64 i=1;i<=m;++i) cin >> p[i];
        for(i64 i=1;i<=m;++i) flg[i] = sum[i] = 0;
        p[0] = -inf, p[m + 1] = inf;
        sort(p + 1, p + m + 1);
        i64 l, r; V += 1e-5;
        ansc = 0, qj.clear(), plc.clear();
        for(i64 i=1;i<=n;++i){
            if(c[i].a > 0){
                if(c[i].v >= V) l = c[i].d, r = L;
                else r = L, l = c[i].d + ceil(double(V * V - c[i].v * c[i].v) / double(2 * c[i].a));
            }else if(c[i].a == 0){
                if(c[i].v < V) continue;
                else l = c[i].d, r = L;
            }else{
                if(c[i].v < V) continue;
                else l = c[i].d, r = c[i].d + floor(double(c[i].v * c[i].v - V * V) / double(-2 * c[i].a));
            }
            cf(l, r);
        }
        for(i64 i=1;i<=m;++i) sum[i] = sum[i-1] + flg[i];
        i64 cnt = 0;
        sort(qj.begin(), qj.end());
        for(i64 i=0;i<(i64)qj.size();++i){
            bool flg = false;
            for(i64 j = plc.size() - 1;j>=0;--j){
                if(plc[j] >= qj[i].second && plc[j] <= qj[i].first){
                    flg = true;
                    break;
                }
            }
            if(!flg){
                plc.push_back(qj[i].first);
                cnt++;
            }
        }
        cout << ansc << ' ' << m - cnt << '\n';
    }
    return 0;
}